package com.ScoresSystem.service.Impl;

import com.ScoresSystem.mapper.StudentMapper;
import com.ScoresSystem.pojo.Student;
import com.ScoresSystem.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    StudentMapper studentMapper;

    public List<Student> selectAllStudents(Map<String, Object> map) {
        // 添加查询条件
        // map.put("sex", "男");
        // map.put("age", "20");
        return studentMapper.selectAllStudents(map);
    }

    @Override
    public List<Student> getAllStudent(String name, int pageIndex, int pageSize) {
        return studentMapper.getAllStudent(name, pageIndex, pageSize);
    }

    @Override
    public int getCount(String studentName) {
        return studentMapper.getCount(studentName);
    }

    @Override
    public Student findStudentByStuNumber(String studentNo) {
        return studentMapper.findStudentByStuNumber(studentNo);
    }

    @Override
    public int addStudent(Student student) {
        return studentMapper.addStudent(student);
    }

    @Override
    public int updateStudent(Student student) {
        return studentMapper.updateStudent(student);
    }

    @Override
    public int deleteStudent(String studentNo) {
        return studentMapper.deleteStudent(studentNo);
    }

    // 查询所有学生姓名
    @Override
    public List<Student> studentSelect() {
        return studentMapper.studentSelect();
    }

    @Override
    public Student login(String userName, String password) {
        return studentMapper.login(userName, password);
    }

    @Override
    public Student findStudent(String studentNo, String oldPassword) {
        return studentMapper.findStudent(studentNo, oldPassword);
    }

    @Override
    public int updatePassword(String studentNo, String newPassword) {
        return studentMapper.updatePassword(studentNo, newPassword);
    }
}
